package com.itheima.service.Impl;

import com.itheima.mapper.DeptMapper;
import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

//@Component
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper DeptMapper;

    /**
     * 查询所有部门
     * @return
     */
    public List<Dept> DeptList() {
        List<Dept> deptList = DeptMapper.DeptList();

        return deptList;
    }

    /**
     * 删除部门
     * @param id
     */
    @Override
    public void DpetDelete(Integer id) {
        DeptMapper.DeptDelete(id);
    }

    /**
     * 添加部门
     * @param dept
     */
    @Override
    public void DeptAdd(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        DeptMapper.DeptAdd(dept);
    }

    /**
     * 根据id查询部门
     * @param id
     * @return
     */
    @Override
    public Dept DeptFindById(Integer id) {
        Dept dept = DeptMapper.DeptFindById(id);
        return dept;
    }

    /**
     * 修改部门
     * @param dept
     */
    @Override
    public void DeptUpdate(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        DeptMapper.DeptUpdate(dept);
    }


}
